//
//  HotelFacilitiesCell.swift
//  DLuxTravel
//
//  Created by 陆涛 on 2018/12/3.
//  Copyright © 2018 imguider. All rights reserved.
//

import UIKit

class HotelFacilitiesCell: BaseCell {

    @IBOutlet weak var layerView: UIView!
    @IBOutlet weak var collectionView: UICollectionView!
    @IBOutlet weak var layout: UICollectionViewFlowLayout!
    
    @IBOutlet weak var collectionViewH: NSLayoutConstraint!
    
    private let width = (kScreenWidth - 60 - 16 * 3) / 4
    
    private let height = 50
    override func awakeFromNib() {
        super.awakeFromNib()
        
        setupUI()
    }
    
    private func setupUI() {
        
        configCell(.container)
        layerView.addShadow(.hotelDetail)
        
        layout.itemSize = CGSize(width: width, height: height)
        
        layout.minimumLineSpacing = 16
        layout.minimumInteritemSpacing = 16
        
        layout.sectionInset = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
        
        collectionViewH.constant = CGFloat(height * 3 + 40 + 16 * 2)
        
        self.collectionView.register(UINib.init(nibName: "HotelFacilitiesSubCCell", bundle: nil), forCellWithReuseIdentifier: "HotelFacilitiesSubCCell")
        
        
    }
}

extension HotelFacilitiesCell: UICollectionViewDataSource, UICollectionViewDelegate {
    
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return 12
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "HotelFacilitiesSubCCell", for: indexPath) as! HotelFacilitiesSubCCell
        
        return cell
    }
}
